<%# Form UI behavior code and details;
Code:
  app/assets/javascripts/sufia/relationships
CSS:
  table.relationships-ajax-enabled : Used by sufia JS app as selector to wire up the UI functionality
  tr.new-row : The basic template row for cloning when user clicks "Add"
  .btn-remove-row : Button to remove its parent TR from the table
  .btn-add-row : Button to clone its parent TR and inject a new row into the table
  input.new-form-control : Input field for client client side validation and additional features
  .message.has-warning : Used to display UI errors related to input values and server errors
HTML Properties:
  table:
    data-query-url : URL base to append newly added work ID to for querying details (title, href)
%>
<div class="form-group multi_value optional managed">
  <%= link_to "Attach New Work", polymorphic_path([main_app, :new, :curation_concerns, :parent, curation_concern.model_name.singular], parent_id: params[:id]), target: "_blank", class: 'btn btn-primary' %>

  <table class="table table-striped related-files relationships-ajax-enabled"
         data-query-url="<%= polymorphic_path([main_app, :curation_concerns, curation_concern.model_name.singular], id: '$id') %>">
    <thead>
    <tr>
      <th>Child Work</th>
      <th>Actions</th>
    </tr>
    </thead>
    <tbody>
    <tr class="hidden">
      <td>
        <% f.object.ordered_fileset_members.each do |fileset| %>
          <input class="related_works_ids work_filesets_ids" name="<%= f.object.model_name.param_key %>[ordered_member_ids][]" type="hidden" value="<%= fileset.id %>">
        <% end %>
      </td>
      <td></td>
    </tr>
    <% f.object.ordered_work_members.each do |member| %>
        <tr>
          <td>
            <%= link_to member.title.first, [main_app, member] %>
            <input class="string multi_value optional form-control related_works_ids work_child_members_ids form-control multi-text-field hidden" value="<%= member.id %>" id="work_child_members_ids" aria-labelledby="work_child_members_ids_label" name="<%= f.object.model_name.param_key %>[ordered_member_ids][]" type="text">
          </td>
          <td>
            <div class="child-actions">
              <%= link_to "Edit", [main_app, :edit, member], target: "_blank", class: 'btn btn-default' %>
              <a class="btn btn-danger btn-remove-row">Remove</a>
            </div>
          </td>
        </tr>
    <% end %>
    <tr class="new-row">
      <td>
        <a href="" class="title hidden"></a>
        <input class="new-form-control string multi_value optional related_works_ids work_child_members_ids form-control multi-text-field" value="" id="work_child_members_ids" aria-labelledby="work_child_members_ids_label" name="<%= f.object.model_name.param_key %>[ordered_member_ids][]" type="text">
        <div class="message has-warning hidden"></div>
      </td>
      <td>
        <div class="child-actions">
          <a href="" class="edit hidden btn btn-default" target="_blank">Edit</a>
          <a class="btn btn-danger btn-remove-row hidden">Remove</a>
          <a class="btn btn-primary btn-add-row">Add</a>
        </div>
      </td>
    </tr>
    </tbody>
  </table>
</div>
